home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / other / systracker_src / src / st_include.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-02-28  |  15.6 KB  |  548 lines

  1. /***************************************************************************/
  2. /* st_include.h - Assorted defines for each module.                        */
  3. /*                                                                         */
  4. /* Copyright © 1999-2000 Andrew Bell. All rights reserved.                 */
  5. /***************************************************************************/
  6.  
  7. #ifndef SYSTRACKER_INCLUDE_H
  8. #define SYSTRACKER_INCLUDE_H
  9.  
  10. /***************************************************************************/
  11. /* Assorted defines */
  12. /***************************************************************************/
  13.  
  14. #undef NULL
  15. #define NULL ((void *)0)
  16.  
  17. /* StampSource should really be handling this year! */
  18. #define YEAR      "1999-2000"
  19. #define EMAILADDY "andrew.ab2000@bigfoot.com"
  20. #define WEBADDY   "http://www.andrewb.exl.co.uk"  
  21.  
  22. /* Size of IO buffer, passed to SetVBuf(). */
  23. #define IO_BUFFER_SIZE   (1024*32)
  24. #define TEMP_BUFFER_SIZE (1024*4)
  25.  
  26. /* One day this will used in all areas of the source */
  27. #define MAXPATHLEN 256
  28.  
  29. #ifndef MAKE_ID
  30. #define MAKE_ID(a, b, c, d) \
  31.   ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  32. #endif
  33.  
  34. /***************************************************************************/
  35. /* System includes */
  36. /***************************************************************************/
  37.  
  38. #ifndef EXEC_TYPES_H
  39. #include <EXEC/types.h>
  40. #endif /* EXEC_TYPES_H */
  41.  
  42. #ifndef EXEC_EXECBASE_H
  43. #include <EXEC/execbase.h>
  44. #endif /* EXEC_EXECBASE_H */
  45.  
  46. #ifndef EXEC_SEMAPHORES_H
  47. #include <EXEC/semaphores.h>
  48. #endif /* EXEC_SEMAPHORES_H */
  49.  
  50. #ifndef EXEC_LIBRARIES_H
  51. #include <EXEC/libraries.h>
  52. #endif /* EXEC_LIBRARIES_H */
  53.  
  54. #ifndef EXEC_TASKS_H
  55. #include <EXEC/tasks.h>
  56. #endif /* EXEC_TASKS_H */
  57.  
  58. #ifndef EXEC_DEVICES_H
  59. #include <EXEC/devices.h>
  60. #endif /* EXEC_DEVICES_H */
  61.  
  62. #ifndef EXEC_NODES_H
  63. #include <EXEC/nodes.h>
  64. #endif /* EXEC_NODES_H */
  65.  
  66. #ifndef EXEC_LISTS_H
  67. #include <EXEC/lists.h>
  68. #endif /* EXEC_LISTS_H */
  69.  
  70. #ifndef EXEC_IO_H
  71. #include <EXEC/io.h>
  72. #endif /* EXEC_IO_H */
  73.  
  74. #ifndef EXEC_PORTS_H
  75. #include <EXEC/ports.h>
  76. #endif /* EXEC_PORTS_H */
  77.  
  78. #ifndef EXEC_MEMORY_H
  79. #include <EXEC/memory.h>
  80. #endif /* EXEC_MEMORY_H */
  81.  
  82. #ifndef DOS_STDIO_H
  83. #include <DOS/stdio.h>
  84. #endif /* DOS_STDIO_H */
  85.  
  86. #ifndef DOS_DOS_H
  87. #include <DOS/dos.h>
  88. #endif /* DOS_DOS_H */
  89.  
  90. #ifndef DOS_DOSTAGS_H
  91. #include <DOS/dostags.h>
  92. #endif /* DOS_DOS_H */
  93.  
  94. #ifndef DOS_DOSEXTENS_H
  95. #include <DOS/dosextens.h>
  96. #endif /* DOS_DOSEXTENS_H */
  97.  
  98. #ifndef DOS_EXALL_H
  99. #include <DOS/exall.h>
  100. #endif /* DOS_EXALL_H */
  101.  
  102. #ifndef DOS_NOTIFY_H
  103. #include <DOS/notify.h>
  104. #endif /* DOS_NOTIFY_H */
  105.  
  106. #ifndef DOS_DATETIME_H
  107. #include <DOS/datetime.h>
  108. #endif /* DOS_DATETIME_H */
  109.  
  110. #ifndef LIBRARIES_ASL_H
  111. #include <LIBRARIES/asl.h>
  112. #endif /* LIBRARIES_ASL_H */
  113.  
  114. #ifndef UTILITY_DATE_H
  115. #include <UTILITY/date.h>
  116. #endif /* UTILITY_DATE_H */
  117.  
  118. #ifndef UTILITY_UTILITY_H
  119. #include <UTILITY/utility.h>
  120. #endif /* UTILITY_UTILITY_H */
  121.  
  122. #ifndef UTILITY_TAGITEM_H
  123. #include <UTILITY/tagitem.h>
  124. #endif /* UTILITY_TAGITEM_H */
  125.  
  126. #ifndef UTILITY_HOOKS_H
  127. #include <UTILITY/hooks.h>
  128. #endif /* UTILITY_HOOKS_H */
  129.  
  130. #ifndef WORKBENCH_STARTUP_H
  131. #include <WORKBENCH/startup.h>
  132. #endif /* WORKBENCH_STARTUP_H */
  133.  
  134. #ifndef WORKBENCH_ICON_H
  135. #include <WORKBENCH/icon.h>
  136. #endif /* WORKBENCH_ICON_H */
  137.  
  138. #ifndef WORKBENCH_WORKBENCH_H
  139. #include <WORKBENCH/workbench.h>
  140. #endif /* WORKBENCH_WORKBENCH_H */
  141.  
  142. #ifndef INTUITION_INTUITION_H
  143. #include <INTUITION/intuition.h>
  144. #endif /* INTUITION_INTUITION_H */
  145.  
  146. #ifndef LIBRARIES_MUI_H
  147. #include <libraries/mui.h>
  148. #endif /* LIBRARIES_MUI_H */
  149.  
  150. extern struct ExecBase *SysBase;
  151.  
  152. #include <clib/muimaster_protos.h>
  153. #include <clib/alib_protos.h>
  154.  
  155. #include <clib/exec_protos.h>
  156. #include <clib/dos_protos.h>
  157. #include <clib/gadtools_protos.h>
  158. #include <clib/intuition_protos.h>
  159. #include <clib/utility_protos.h>
  160. #include <clib/asl_protos.h>
  161. #include <clib/wb_protos.h>
  162. #include <clib/icon_protos.h>
  163.  
  164. #ifdef __MAXON__
  165. #include <pragma/exec_lib.h>
  166. #include <pragma/dos_lib.h>
  167. #include <pragma/gadtools_lib.h>
  168. #include <pragma/intuition_lib.h>
  169. #include <pragma/utility_lib.h>
  170. #include <pragma/asl_lib.h>
  171. #include <pragma/wb_lib.h>
  172. #include <pragma/icon_lib.h>
  173. #endif /* __MAXON__ */
  174.  
  175. #ifdef __VBCC__
  176. #include <inline/exec_protos.h>
  177. #include <inline/dos_protos.h>
  178. #include <inline/gadtools_protos.h>
  179. #include <inline/intuition_protos.h>
  180. #include <inline/utility_protos.h>
  181. #include <inline/asl_protos.h>
  182. #include <inline/wb_protos.h>
  183. #include <inline/icon_protos.h>
  184. #endif
  185.  
  186. #ifdef _DCC
  187. #include <pragmas/exec_pragmas.h>
  188. #include <pragmas/dos_pragmas.h>
  189. #include <pragmas/gadtools_pragmas.h>
  190. #include <pragmas/intuition_pragmas.h>
  191. #include <pragmas/utility_pragmas.h>
  192. #include <pragmas/asl_pragmas.h>
  193. #include <pragmas/wb_pragmas.h>
  194. #include <pragmas/icon_pragmas.h>
  195. #endif
  196.  
  197. /* ANSI */
  198.  
  199. #include <stdio.h>
  200. #include <string.h>
  201.  
  202. #pragma header
  203.  
  204. /***************************************************************************/
  205. /* st_main.c */
  206. /***************************************************************************/
  207.  
  208. #define STACKSIZE        (1024*32) /* 32KB of stack space */
  209.  
  210. extern struct Process *SysTrackerProcess;
  211. extern BOOL cfg_RemovePaths;
  212. extern BOOL cfg_BeSystemLegal;
  213. extern BOOL cfg_AutoUpdate;
  214. extern BOOL cfg_DebugMode;
  215. extern BOOL cfg_TrackUnusedResources;
  216. extern BOOL cfg_ShowUnusedResources;
  217.  
  218. /***************************************************************************/
  219. /* st_memory.c */
  220. /***************************************************************************/
  221.  
  222. #define SAFETY            30L      /* Sometimes used on allocations */
  223. #define POOL_PUDDLESIZE (8*1024)
  224. #define POOL_THRESHSIZE (POOL_PUDDLESIZE/4) 
  225.  
  226. /***************************************************************************/
  227. /* st_artl.c */
  228. /***************************************************************************/
  229.  
  230. /* ARTL defines */
  231.  
  232. struct AppList
  233. {
  234.   struct List            al_List;
  235.   struct SignalSemaphore al_Key;
  236. };
  237.  
  238. #define AppList_SIZE sizeof(struct AppList)
  239.  
  240. struct AppNode
  241. {
  242.   struct Node       an_Node;
  243.   UWORD             an_Status;    /* AN_STATUS_#? */
  244.   struct Task      *an_TaskPtr;   /* Don't access the struct itself! */
  245.     /* Set with ARTL_SetTNTaskName() ; Free with MEM_FreeVec() */  
  246.   UBYTE            *an_TaskName;
  247.   struct DateStamp  an_TrackDate;
  248.   ULONG             an_TaskType;
  249.     /* Set with ARTL_SetTNCmdName() ; Free with MEM_FreeVec() */
  250.   UBYTE            *an_CmdName;
  251.   ULONG             an_LaunchType;
  252.   BPTR              an_SegList;
  253.   struct List       an_TrackerList;
  254. };
  255.  
  256. enum
  257. {
  258.   AN_STATUS_UNKNOWN = 0,
  259.   AN_STATUS_ALIVE,
  260.   AN_STATUS_DEAD,
  261. };
  262.  
  263. #define AppNode_SIZE sizeof(struct AppNode)
  264.  
  265. struct TrackerNode
  266. {
  267.   struct Node       tn_Node;           /* We're part of a chain           */
  268.   BOOL              tn_InUse;          /* Resource currently in use?      */
  269.   ULONG             tn_ID;             /* PMSGID_#?                       */
  270.   struct DateStamp  tn_TrackDate;      /* For future use                  */
  271.  
  272.   /* For resources that have no from of Unique ID, like libs. */
  273.   LONG              tn_OpenCnt;        /* Keep this signed                */
  274.   UBYTE             tn_OpenCntTxt[12]; /* Used by the lister hook only    */
  275.  
  276.   /************************************** PMSGID_OPENLIBRARY **************/
  277.   UBYTE            *tn_LibName;        /* Free with MEM_FreeVec()         */
  278.   ULONG             tn_LibVer;         /* Version passed to OpenLibrary() */
  279.   struct Library   *tn_LibBase;        /* Don't access the struct!        */
  280.  
  281.   /************************************** PMSGID_OPENDEVICE ***************/
  282.   UBYTE            *tn_DevName;        /* Free with MEM_FreeVec()         */
  283.   ULONG             tn_DevUnitNum;     /* UnitNum passed to OpenDevice()  */
  284.   ULONG          tn_DevUnitNumTxt[12]; /* UnitNum passed to OpenDevice()  */
  285.   struct IORequest *tn_DevIOReq;       /* UID - Don't access the struct!  */
  286.   ULONG             tn_DevFlags;       /* Flags passed to OpenDevice()    */
  287.  
  288.   /************************************** PMSGID_OPENFONT *****************/
  289.   struct TextAttr  *tn_FontTextAttr;   /* Don't access the struct!        */
  290.   struct TextFont  *tn_FontTextFont;   /* UID - Don't access the struct!  */
  291.   UBYTE            *tn_FontName;       /*                                 */
  292.   UWORD             tn_FontYSize;      /* Free with MEM_FreeVec()         */
  293.   UBYTE             tn_FontStyle;      /*                                 */
  294.   UBYTE             tn_FontFlags;      /*                                 */
  295.  
  296.   /************************************** PMSGID_OPEN *********************/
  297.   UBYTE            *tn_FHName;         /* Free with MEM_FreeVec()         */
  298.   LONG              tn_FHMode;         /*                                 */
  299.   BPTR              tn_FH;             /* UID                             */
  300.  
  301.   /************************************** PMSGID_LOCK *********************/
  302.   UBYTE            *tn_LockName;       /* Free with MEM_FreeVec()         */
  303.   LONG              tn_LockMode;       /*                                 */
  304.   BPTR              tn_Lock;           /* UID                             */
  305.  
  306.   /************************************************************************/
  307.   UBYTE            *tn_CurDirName;     /* For PMSGID_OPEN/PMSGID_LOCK IDs */
  308. };
  309.  
  310. #define TrackerNode_SIZE sizeof( struct TrackerNode )
  311.  
  312. enum
  313. {
  314.   ADDMODE_APPEND,
  315.   ADDMODE_ALPHABETICALLY,
  316. };
  317.  
  318.  
  319. /***************************************************************************/
  320. /* st_gui.c */
  321. /***************************************************************************/
  322.  
  323. enum /* This this in sync with the above cycle entries */
  324. {
  325.   TRACKMODE_LIBRARIES = 0,
  326.   TRACKMODE_DEVICES,
  327.   TRACKMODE_FONTS,
  328.   TRACKMODE_LOCKS,
  329.   TRACKMODE_FILEHANDLES,
  330. };
  331.  
  332. #define MyKeyButton(name, key, shorthelp) \
  333.   TextObject,\
  334.     ButtonFrame,\
  335.     MUIA_ShortHelp    , shorthelp,\
  336.     MUIA_Font, MUIV_Font_Button,\
  337.     MUIA_Text_Contents, name,\
  338.     MUIA_Text_PreParse, "\33c",\
  339.     MUIA_Text_HiChar  , key,\
  340.     MUIA_ControlChar  , key,\
  341.     MUIA_InputMode    , MUIV_InputMode_RelVerify,\
  342.     MUIA_Background   , MUII_ButtonBack,\
  343.     End
  344.         
  345. #define nmTitle(txt) \
  346.   { NM_TITLE, txt, NULL, 0, 0, NULL },
  347. #define nmItem(txt, commkey, flags, mid) \
  348.   { NM_ITEM, txt, commkey, flags, 0, (APTR) mid },
  349. #define nmSub(txt, commkey, flags, mid) \
  350.   { NM_SUB, txt, commkey, flags, 0, (APTR) mid },
  351. #define nmBar \
  352.   { NM_ITEM, NM_BARLABEL, NULL, 0, 0, NULL },
  353. #define nmEnd \
  354.   { NM_END, NULL, NULL, 0, 0, NULL }
  355.  
  356.  
  357. enum /* Object IDs */
  358. {
  359.   OID_START = 1,
  360.  
  361.   OID_APP,              /* Not used yet */
  362.   OID_APP_DOUBLESTART,
  363.  
  364.   OID_MAIN_WINDOW,
  365.   OID_MAIN_TRKMODE,
  366.   OID_MAIN_SAVE,
  367.   OID_MAIN_UPDATE,
  368.   OID_MAIN_QUIT,
  369.   OID_MAIN_TRACKERLIST,
  370.   OID_MAIN_TRACKERLISTVIEW,
  371.   OID_MAIN_TRACKERLISTVIEW_DOUBLECLICK,
  372.   OID_MAIN_TRACKERLISTVIEW_SINGLECLICK,
  373.   OID_MAIN_OPENCNT,
  374.   OID_MAIN_APPLISTVIEW,
  375.   OID_MAIN_APPLISTVIEW_SINGLECLICK,
  376.   OID_MAIN_APPLIST,
  377.   OID_MAIN_MENU_PROJECT_ABOUT,
  378.   OID_MAIN_MENU_PROJECT_ABOUT_MUI,
  379.   OID_MAIN_MENU_PROJECT_SETTINGS_MUI,
  380.   OID_MAIN_MENU_PROJECT_HIDE,
  381.   OID_MAIN_MENU_PROJECT_QUIT,
  382.   OID_MAIN_MENU_CONTROL_RESET,
  383.   OID_MAIN_MENU_CONTROL_CLEARDEADAPPS,
  384.   OID_MAIN_MENU_CONTROL_CLEARUNUSEDRES,
  385.   OID_MAIN_MENU_CONTROL_TRACKUNUSEDRES,
  386.   OID_MAIN_MENU_CONTROL_SHOWUNUSEDRES,
  387.  
  388.   OID_APPUSING_WINDOW,
  389.   OID_APPUSING_RESNAME,
  390.   OID_APPUSING_LIST,
  391.   OID_APPUSING_LISTVIEW,
  392.   OID_APPUSING_EXIT,
  393.  
  394.   OID_AMOUNT
  395. };
  396.  
  397. /***************************************************************************/
  398. /* st_patch.c */
  399. /***************************************************************************/
  400.  
  401. extern ULONG LVOOpenLibrary;     /* Pull the LVOs from amiga.lib */
  402. extern ULONG LVOCloseLibrary;
  403. extern ULONG LVOOpenDevice;
  404. extern ULONG LVOCloseDevice;
  405. extern ULONG LVOMakeLibrary;
  406. extern ULONG LVOOpenFont;
  407. extern ULONG LVOCloseFont;
  408. extern ULONG LVOOpenDiskFont;
  409.  
  410. extern ULONG LVOOpen;
  411. extern ULONG LVOClose;
  412. extern ULONG LVOLock;
  413. extern ULONG LVOUnLock;
  414. extern ULONG LVOOpenFromLock;
  415.  
  416. /* This structure MUST remain in sync with
  417.    the one in st_patches_asm.s!!! */
  418.  
  419. struct PatchMsg
  420. {
  421.   struct Message      pmsg_MsgHeader;
  422.   LONG                pmsg_ID;
  423.   struct Task        *pmsg_TaskPtr;
  424.   UBYTE              *pmsg_TaskName;
  425.   ULONG               pmsg_TaskType;
  426.   BOOL                pmsg_TaskFrozen;
  427.   UWORD               pmsg_Padding01;  /* Keep everything align to 32 bits. */
  428.   UBYTE              *pmsg_CmdName;
  429.   ULONG               pmsg_LaunchType; /* LT_#? */
  430.   BPTR                pmsg_SegList;    /* Only valid if LaunchType == LT_CLI */
  431.  
  432.   ULONG               pmsg_LibType;    /* Not yet implemented */
  433.   UBYTE              *pmsg_LibName;
  434.   ULONG               pmsg_LibVer;
  435.   struct Library     *pmsg_LibBase;
  436.  
  437.   UBYTE              *pmsg_DevName;
  438.   ULONG               pmsg_DevUnitNum;
  439.   struct IORequest   *pmsg_DevIOReq;
  440.   ULONG               pmsg_DevFlags;
  441.  
  442.   struct TextAttr    *pmsg_FontTextAttr;
  443.   struct TextFont    *pmsg_FontTextFont;
  444.   UBYTE              *pmsg_FontName;
  445.   UWORD               pmsg_FontYSize;
  446.   UBYTE               pmsg_FontStyle;
  447.   UBYTE               pmsg_FontFlags;
  448.  
  449.   UBYTE              *pmsg_FHName;
  450.   LONG                pmsg_FHMode;
  451.   BPTR                pmsg_FH;
  452.   
  453.   UBYTE              *pmsg_LockName;
  454.   LONG                pmsg_LockMode;
  455.   BPTR                pmsg_Lock;
  456.  
  457.   UBYTE              *pmsg_CurDirName;
  458. };
  459.  
  460. #define LT_NA  0                 /* For pmsg_LaunchType */
  461. #define LT_CLI 1
  462. #define LT_WB  2
  463.  
  464. #define PMSGID_ALL              -1 /* Special values are signed */
  465. #define PMSGID_UNKNOWN           0
  466. #define PMSGID_OPENLIBRARY       1
  467. #define PMSGID_OPENDEVICE        2
  468. #define PMSGID_CLOSELIBRARY      3
  469. #define PMSGID_CLOSEDEVICE       4
  470. #define PMSGID_OPENFONT          5
  471. #define PMSGID_CLOSEFONT         6
  472. /*#define PMSGID_OPENDISKFONT      7 *** Obsolete *** */
  473. /*#define PMSGID_MAKELIBRARY       8 *** Obsolete *** */
  474. #define PMSGID_OPEN              9
  475. #define PMSGID_CLOSE             10
  476. #define PMSGID_LOCK              11
  477. #define PMSGID_UNLOCK            12
  478. #define PMSGID_OPENFROMLOCK      13
  479.  
  480. /* These are located in the st_patches assembly module. */
  481.  
  482. #ifdef __MAXON__
  483. extern void PATCH_DeletePatchMsg( register __a0 struct PatchMsg *PMsg );
  484. extern UBYTE *PATCH_StrToVec( register __a0 UBYTE *Str );
  485. APTR PATCH_AllocVec( register __d0 ULONG ByteSize );
  486. void PATCH_FreeVec( register __a1 APTR Vec );
  487. #endif /* __MAXON__ */
  488.  
  489. #ifdef __VBCC__
  490. extern void PATCH_DeletePatchMsg( __reg("a0") struct PatchMsg *PMsg );
  491. extern UBYTE *PATCH_StrToVec( __reg("a0") UBYTE *Str );
  492. APTR PATCH_AllocVec( __reg("d0") ULONG ByteSize );
  493. void PATCH_FreeVec( __reg("a1") APTR Vec );
  494. #endif /* __VBCC__ */
  495.  
  496. #ifdef _DCC
  497. extern void PATCH_DeletePatchMsg( __a0 struct PatchMsg *PMsg );
  498. extern UBYTE *PATCH_StrToVec( __a0 UBYTE *Str );
  499. APTR PATCH_AllocVec( __d0 ULONG ByteSize );
  500. void PATCH_FreeVec( __a1 APTR Vec );
  501. #endif /* _DCC */
  502.  
  503. extern APTR PATCH_NewOpenLibrary;
  504. extern APTR PATCH_NewCloseLibrary;
  505. extern APTR PATCH_NewOpenDevice;
  506. extern APTR PATCH_NewCloseDevice;
  507. extern APTR PATCH_NewMakeLibrary;
  508.  
  509. extern APTR PATCH_NewOpenFont;
  510. extern APTR PATCH_NewCloseFont;
  511. extern APTR PATCH_NewOpenDiskFont;
  512.  
  513. extern APTR PATCH_NewOpen;
  514. extern APTR PATCH_NewClose;
  515. extern APTR PATCH_NewLock;
  516. extern APTR PATCH_NewUnLock;
  517. extern APTR PATCH_NewOpenFromLock;
  518.  
  519. /***************************************************************************/
  520. /* st_libs.c */
  521. /***************************************************************************/
  522.  
  523. struct GetLibs
  524. {
  525.   UBYTE           *gl_Name;
  526.   LONG             gl_Version;
  527.   struct Library **gl_LibBasePtr;
  528.   ULONG            gl_Mode;       /* GL_#? */
  529. };
  530.  
  531. #define GL_OPTIONAL 1
  532. #define GL_ABSOLUTE 2
  533.  
  534. extern struct Library *IntuitionBase;
  535. extern struct Library *UtilityBase;
  536. extern struct Library *WorkbenchBase;
  537. extern struct Library *DiskFontBase;
  538. extern struct Library *GfxBase;
  539.  
  540. /* Pull these in from the startup code */
  541.  
  542. extern struct ExecBase *SysBase;
  543. extern struct DosLibrary *DOSBase;
  544.  
  545. #endif /* SYSTRACKER_INCLUDE_H */
  546.  
  547.  
  548.